class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) {this.val = val;}
    TreeNode(int val,TreeNode left,TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}
public class Main {

    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
    //后序遍历

    /**
     * 布尔二叉树
     * @param root
     * @return
     */
    public boolean evaluateTree(TreeNode root) {
        //跳出递归语句！！！
        if(root.left == null) {
            return root.val == 0 ? false : true;
        }
        //递归体
        boolean left = evaluateTree(root.left);
        boolean right = evaluateTree(root.right);
        //整合   返回结果~~~
        return root.val == 2 ? left | right : left & right;
    }

    public static TreeNode pruneTree(TreeNode root) {

        if(root == null) {
            return null;
        }

        root.left = pruneTree(root.left); //处理左子树
        root.right = pruneTree(root.right);//处理右子树
        if(root.left == null && root.right == null && root.val == 0) { //出口加条件
            root = null;
        }

        return root;
    }
    
}